package com.leadership.api.dao;

import java.util.List;
import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.leadership.entity.project.UserProject;
import com.leadership.entity.user.User;

/**
 * @author haiyan_xiao
 *
 */
@Dao("hibernate")
public interface UserProjectDao {

    /**
     * 
     * @param user
     * @param projectId
     * @return
     */
    @Query("FROM UserProject WHERE disabled = false AND user = :user AND projectId = :projectId")
    public UserProject load(@Variable("user") User user, @Variable("projectId") Long projectId);
    
    /**
     * 
     * @param projectId
     * @return
     */
    @Query("FROM UserProject WHERE disabled = false AND projectId = :projectId")
    public List<UserProject> listUserProject(@Variable("projectId") Long projectId);
    
    /**
     * 
     * @param userId
     * @return
     */
    @Query("FROM UserProject WHERE disabled = false AND user.id = :userId")
    public List<UserProject> listUserProjectByUser(@Variable("userId") Long userId);
}
